﻿@model AccountDefailModel
@{
    ViewBag.Title = "会员详情";
    Layout = "~/Views/Shared/_ContentLayout.cshtml";

    ADZ_MasterEntities dbcontext = new ADZ_MasterEntities();
    Dictionary<string, string> dc = new Dictionary<string, string>();
}

<form id="S_Form" action="@Url.Action("saveDefails", "account")" method="post" class="definewidth m20" enctype="multipart/form-data">
    <h5>
        会员详细信息显示，包括基本信息，收货地址，发票信息等。
    </h5>
    <input type="hidden" name="uid" value="@Model.member.uid" />
    <table class="table table-bordered table-hover definewidth m10">
        <tr>
            <td width="10%" class="tableleft">代购编号</td>
            <td>
                @Model.member.replace_buyer_NO
            </td>
            <td width="10%" class="tableleft">手机号</td>
            <td>
                @Model.member.account_mobile
            </td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">会员名称</td>
            <td>
                @Model.member.member_name
            </td>
            <td class="tableleft">会员等级</td>
            <td>
                <div class="green">@Model.member.member_level_name</div>
            </td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">会员状态</td>
            <td>
                @switch (Model.member.account_status)
                {
                    case 0:
                        @:<div class="green">正常</div>
                        break;
                    case 9:
                        @:<div class="red">停用</div>
                        break;
                }
            </td>
            <td class="tableleft">注册时间</td>
            <td>
                @Model.member.create_time.ToString(1)
            </td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">余额</td>
            <td>
                @Model.member.account_balance
            </td>
            <td class="tableleft">代购比例</td>
            <td>
                @Model.member.buyer_rate
            </td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">推荐比例</td>
            <td>
                @Model.member.recommend_rate
            </td>
            <td class="tableleft">加价比例</td>
            <td>
                @Model.member.add_rate
            </td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">业务员 </td>
            <td>
                @{
                    bool bind = false;
                    if (Model.member.manage_uid.HasValue && Model.member.manage_uid.Value > 0)
                    {
                        var memberinfo = UserBiz.Instance.GetUserInfoById(Model.member.manage_uid.Value);
                        if (memberinfo != null)
                        {
                            bind = true;
                            <info class="green">@memberinfo.realName-@memberinfo.mobile</info>
                        }
                    }
                    if (!bind)
                    {
                        <info class="red">未绑定</info>
                    }
                }
            </td>
            <td class="tableleft">推荐人</td>
            <td>
                @{
                    if (Model.member.member_level > 0)
                    {
                        var invite = dbcontext.ADZ_InviteCode.FirstOrDefault(t => t.rel_uid == Model.member.uid);
                        if (invite != null)
                        {
                            var inviteinfo = dbcontext.ADZ_MemberMaster.FirstOrDefault(t => t.uid == invite.uid);
                            if (inviteinfo != null)
                            {
                                <info>@inviteinfo.member_name @inviteinfo.account_mobile</info>
                            }
                        }
                    }
                }
            </td>
        </tr>
    </table>
    <h5>
        会员基本信息
    </h5>
    <table class="table table-bordered table-hover definewidth m10">
        <tr>
            <td width="10%" class="tableleft">姓名</td>
            <td>
                <input type="text" name="real_name" maxlength="50" value="@Model.member.real_name" />

            </td>
            <td width="10%" class="tableleft">性别</td>
            <td>
                <input type="radio" name="sex" style="vertical-align:middle; margin-bottom:6px;" value="1" />男
                <input type="radio" name="sex" style="vertical-align:middle; margin-bottom:6px;" value="2" />女
            </td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">公司名</td>
            <td>
                <input type="text" name="company_name" maxlength="50" value="@Model.member.company_name" />
            </td>
            <td width="10%" class="tableleft">地址</td>
            <td>
                <input type="text" name="address" maxlength="200" value="@Model.member.address" />
            </td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">联系方式</td>
            <td>
                <input type="text" name="contact_mobile" maxlength="50" value="@Model.member.contact_mobile" />
            </td>
            <td width="10%" class="tableleft">身份证号</td>
            <td>
                <input type="text" name="id_number" maxlength="50" value="@Model.member.id_number" />
            </td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">公司电话</td>
            <td>
                <input type="text" name="company_telephone" maxlength="50" value="@Model.member.company_telephone" />
            </td>
            <td class="tableleft">公司地址</td>
            <td>
                <input type="text" name="company_address" maxlength="200" value="@Model.member.company_address" />
            </td>
        </tr>
        <tr>
            <td class="tableleft">客户类型</td>
            <td>
                <select name="customer_type" id="customer_type">
                    @{
                        dc = new Dictionary<string, string>();
                        MyEnumHelper.GetEnumItems(typeof(customer_type)).ForEach(t =>
                        {
                            dc.Add(t.Value.ToString(), t.Description);
                        });
                    }
                    @HtmlPagerHelper.ShowSelectOpton(dc, Model.member.customer_type.ToString());
                </select>
            </td>
            <td width="10%" class="tableleft">备注信息</td>
            <td>
                <textarea name="remark" style="width:80%;" maxlength="250" cols="4">@Model.member.remark</textarea>
            </td>
        </tr>
        <tr>
            <td colspan="4">
                <button type="submit" class="btn btn-primary">保存</button>
            </td>
        </tr>
    </table>
    <h5>
        会员收货地址
    </h5>
    <table class="table table-bordered table-hover definewidth m10">
        <thead>
            <tr>
                <th>收货人</th>
                <th>手机号</th>
                <th>收货地址</th>
                <th>是否默认地址</th>
            </tr>
        </thead>
        @if (Model.addressList != null && Model.addressList.Count != 0)
        {
            int index = 0;
            foreach (var m in Model.addressList)
            {
                index++;
                <tr class="@HtmlPagerHelper.TrClass(index)">
                    <td>@m.receiver</td>
                    <td>@m.receiver_telephone</td>
                    <td>@m.address</td>
                    <td>
                        @switch (m.is_default)
                        {
                            case 0:
                                @:<div class="red">否</div>
                                break;
                            case 1:
                                @:<div class="green">是</div>
                                break;
                        }
                    </td>
                </tr>
            }
        }
    </table>
    <h5>
        会员发票信息
    </h5>
    <table class="table table-bordered table-hover definewidth m10">
        <thead>
            <tr>
                <th>发票类型</th>
                <th>发票抬头</th>
                <th>发票内容</th>
                <th>纳税人识别号</th>
            </tr>
        </thead>
        @if (Model.invoiceList != null && Model.invoiceList.Count != 0)
        {
            int index = 0;
            foreach (var m in Model.invoiceList)
            {
                index++;
                <tr class="@HtmlPagerHelper.TrClass(index)">
                    <td>
                        @switch (m.invoice_type)
                        {
                            case 0:
                                @:<div>个人</div>
                                break;
                            case 1:
                                @:<div>企业</div>
                                break;
                        }
                    </td>
                    <td>@m.invoice_title</td>
                    <td>@m.invoice_content</td>
                    <td>@m.taxpayer_ID</td>
                </tr>
            }
        }
    </table>
    <div><button type="button" backpageid="account/accountlist" class="btn btn-success" name="backid" id="backid">返回</button></div>
</form>
<script type="text/javascript">
    reloadHandler = function () {
        //document.execCommand('Refresh');
        //location.replace(location.href);
        window.location.reload();
    }
    $(function () {
        //绑定信息
        switch ('@Model.member.sex') {
            case '1':
                $("input[name='sex']").get(0).checked = true;
                break;
            case '2':
                $("input[name='sex']").get(1).checked = true;
                break;
            default:
                $("input[name='sex']").get(0).checked = true;
                break;
        }

        var validator = $('form').validate({
            errorLabelContainer: $("#errorContainer"),
            errorElement: "span",
            submitHandler: function (form) {
                $(form).ajaxSubmit(function (result) {
                    ShowActionResult(result, reloadHandler);
                });
            }
        });
    });
</script>